(ns ca.uoit.molly.tests.dev
  (:use [ca.uoit.molly.db-molly]
        [ca.uoit.molly.lucene-helper]
        [ca.uoit.molly.lucene-molly]
        [ca.uoit.molly.mycampus :as mycampus])
 (:require [clojure.zip :as zip]))

(def counter (ref 0))
(defn inc-counter [& args]
  (do
    (when (zero? (mod @counter 100)) (println @counter))
    (dosync (alter counter inc))))

;(defn pack [grp-def rows]
;  (do
;    (when (zero? (mod @counter 100)) (println @counter))
;    (let [tree (apply build-tree (for [row rows] (split-row grp-def row)))]
;      ;(println tree)
;      (print-tree tree))
;    (dosync (alter counter inc))))

(defn- func [grp-def denorm-grp]
  (do
    (inc-counter)
    (println (denorm-group-to-doc grp-def denorm-grp))))

(time (for-all-groups mycampus/*db* mycampus/*course-schedule* func))
